package com.tank.game.api;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * 启动面板工具类
 *
 * @author Zed
 */
public abstract class LaunchPanelUtils {

    private static final String CLASS_PATH = "com.tank.game.launch";

    public static LaunchPanel LAUNCH_PANEL = null;

    static {
        // SPI
        ServiceLoader<LaunchPanel> load = ServiceLoader.load(LaunchPanel.class);
        Iterator<LaunchPanel> it = load.iterator();
        //只认com.tank.game.launch类路径下的Panel启动类,且只拿第一个，其他模块不作处理
        while (it.hasNext()) {
            LaunchPanel next = it.next();
            if (next.getClass().getName().contains(CLASS_PATH)) {
                LAUNCH_PANEL = next;
            }
        }
    }

}